<div class="layui-form-item layui-form-text">
	<label class="layui-form-label">子题目内容</label>
	<div class="layui-input-block">
		<!-- 加载编辑器的容器 -->
	    <script id="container5" name="tiakong[title]" type="text/plain">
	        <{$topic_info.subject_text|default:""}>
	    </script>
	</div>
</div>

<div id="an_tiankong_box">
	<div class="layui-form-item">
		<a href="javascript:;" class="layui-btn layui-btn-primary add_text"><i class="layui-icon"></i>新增文本</a>
		<a href="javascript:;" class="layui-btn layui-btn-primary add_symbol"><i class="layui-icon"></i>新增符号</a>
		<a href="javascript:;" class="layui-btn layui-btn-primary add_number"><i class="layui-icon"></i>新增数字</a>
		<a href="javascript:;" class="layui-btn layui-btn-primary add_calc"><i class="layui-icon"></i>新增算式</a>
	</div>
</div>

<div class="layui-form-item layui-form-text">
	<label class="layui-form-label">答案解析</label>
	<div class="layui-input-block">
		<textarea name="tiakong[analysis]" placeholder="请输入内容" class="layui-textarea"></textarea>
	</div>
</div>

<script>
	layui.use(['form'], function(){
		var form = layui.form();
		form.render();

		$(".add_text").click(function(){
			var _this = $(this);
			var tiankong_total = _this.closest("#an_tiankong_box").find(".tiankong_answer").length;
			var index = tiankong_total+1;
			var html = '<div class="layui-form-item">';
			html +=	'<label class="layui-form-label">题目答案' + index +'</label>';
			html +=	'<div class="layui-input-block">';
			html +=	'<input type="text" placeholder="文本" name="tiakong[text]['+index+']" lay-verify="required" autocomplete="off" class="layui-input tiankong_answer">';
			html += '</div></div>';
			_this.closest(".layui-form-item").before(html);
		});

		$(".add_symbol").click(function(){
			var _this = $(this);
			var tiankong_total = _this.closest("#an_tiankong_box").find(".tiankong_answer").length;
			var index = tiankong_total+1;
			var html = '<div class="layui-form-item">';
			html +=	'<label class="layui-form-label">题目答案' + index +'</label>';
			html +=	'<div class="layui-input-block">';
			html += '<select name="tiakong[symbol]['+index+']" class="tiankong_answer" lay-search>';
	    	html +=	'<option value="0">选择符号</option>';
	    	html +=	'<option value="+">+</option>';
	    	html +=	'<option value="-">-</option>';
	    	html +=	'<option value="*">*</option>';
	    	html +=	'<option value="/">/</option>';
	    	html +=	'<option value="(">(</option>';
	    	html +=	'<option value=")">)</option>';
	    	html +=	'<option value=">">></option>';
	    	html +=	'<option value="≥">≥</option>';
	    	html +=	'<option value="<"><</option>';
	    	html +=	'<option value="≤">≤</option>';
	    	html +=	'<option value="=">=</option>';
	    	html +=	'<option value="[">[</option>';
	    	html +=	'<option value="]">]</option>';
			html +=	'</select>';
			html += '</div></div>';
			_this.closest(".layui-form-item").before(html);
			form.render('select');
		})

		$(".add_number").click(function(){
			var _this = $(this);
			var tiankong_total = _this.closest("#an_tiankong_box").find(".tiankong_answer").length;
			var index = tiankong_total+1;
			var html = '<div class="layui-form-item">';
			html +=	'<label class="layui-form-label">题目答案' + index +'</label>';
			html +=	'<div class="layui-input-block">';
			html +=	'<input type="text" placeholder="数字" name="tiakong[number]['+index+']" lay-verify="required" autocomplete="off" class="layui-input tiankong_answer">';
			html += '</div></div>';
			_this.closest(".layui-form-item").before(html);
		});

		$(".add_calc").click(function(){
			var _this = $(this);
			var tiankong_total = _this.closest("#an_tiankong_box").find(".tiankong_answer").length;
			var index = tiankong_total+1;
			var html = '<div class="layui-form-item">';
			html +=	'<label class="layui-form-label">题目答案' + index +'</label>';
			html +=	'<div class="layui-input-block">';
			html +=	'<input type="text" placeholder="算式" name="tiakong[calc]['+index+']" lay-verify="required" autocomplete="off" class="layui-input tiankong_answer">';
			html += '</div></div>';
			_this.closest(".layui-form-item").before(html);
		});
	});
</script>